﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DLM.Infrastructure.Domain;

namespace DLM.Domain.Model
{
    public class Remark : IValidatableObject, IAggregateRoot
    {
        public int RemarkID { get; set; }

        [Required(ErrorMessage="请选择正确的活动")]
        public int PartyID { get; set; }

        [Required(ErrorMessage="评论内容部允许为空")]
        [StringLength(100, ErrorMessage = "最大长度为100")]
        public string Content { get; set; }

        [Required(ErrorMessage="用户不允许为空")]
        public int UserID { get; set; }

        [Required(ErrorMessage="活动评分不允许为空")]
        [RegularExpression(@"^[1-9]\d*$", ErrorMessage = "评分值只允许1-10")]
        public int Rate { get; set; }

        public System.DateTime CreateDate { get; set; }


        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (Rate < 0)
            {
                yield return new ValidationResult("评价不能低于0分");
            }
        }
    }
}
